package com.atguigu.mybatisplusdemo.controller;

import com.atguigu.mybatisplusdemo.domain.ResponseResult;
import com.atguigu.mybatisplusdemo.entity.User;
import com.atguigu.mybatisplusdemo.service.LoginServcie;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {
    @Autowired
    private LoginServcie loginServcie;

    @PostMapping("/user/login")
    public ResponseResult login(@RequestBody User user){
        user.setUserName(user.getUserName().strip());
        user.setPassword(user.getPassword().strip());
        return loginServcie.login(user);
    }

    @RequestMapping("/user/logout")
    public ResponseResult logout(){
        return loginServcie.logout();
    }
}